﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;

namespace Temp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("程序启动中.....................");
            string directory = Environment.CurrentDirectory;
            foreach (Process thisproc in Process.GetProcesses())
            {
                if (thisproc.ProcessName.Equals("Spider") || thisproc.ProcessName.Equals("Update_Spider.exe"))
                {
                    thisproc.Kill();
                }
            }
            while (true)
            {
                Process[] p = Process.GetProcessesByName("Spider");
                if (p.Length < 1)
                {
                    break;
                }
            }
            string old = directory + "\\Spider.exe";
            if (File.Exists(old))
            {
                File.Delete(old);
            }
            else
            {
                return;
            }
            string newfile = directory + "\\Update_Spider.exe";
            if (File.Exists(newfile))
            {
                File.Move(newfile, old);
            }
            else
            {
                return;
            }
            File.Delete(newfile);
            Process.Start(old);//启动升级后的文件
            Console.WriteLine("程序启动完毕.....................");
        }
    }
}
